package com.example.neusoft.widgettest307flb;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TextView;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity {
    private Button button=null;
    private ImageView iv=null;
    private EditText et=null;
    private RadioGroup genderGroup=null;
    private RadioButton femaleRadioButton=null;
    private RadioButton maleRadioButton=null;
    private TextView tv=null;
    private Button btn_intent=null;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        genderGroup=(RadioGroup)findViewById(R.id.genderGroup);
        femaleRadioButton=(RadioButton)findViewById(R.id.female);
        maleRadioButton=(RadioButton)findViewById(R.id.male);
        et=(EditText)findViewById(R.id.et);
        genderGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, int checkedId) {
                if(checkedId==femaleRadioButton.getId()){
                    Toast.makeText(getApplicationContext(),"女性",Toast.LENGTH_SHORT).show();
                }else if(checkedId==maleRadioButton.getId()){
                    Toast.makeText(getApplicationContext(),"男性",Toast.LENGTH_SHORT).show();
                }
            }
        });

        btn_intent=(Button)findViewById(R.id.btn_intent);
        btn_intent.setOnClickListener(new View.OnClickListener(){
            @Override
            public void onClick(View view){
                Intent intent =new Intent(MainActivity.this,IntentActivity.class);
                String str= et.getText().toString();
                intent.putExtra("param",str);
                startActivity(intent);
            }
        });
    }
    public void button(View view){
        et=(EditText)findViewById(R.id.et);
        tv=(TextView)findViewById(R.id.tv);
       String str= et.getText().toString();
        tv.setText(str);
        Toast.makeText(getApplicationContext(),str,Toast.LENGTH_SHORT).show();

    }
    public void imageButton(View view){
        Toast.makeText(getApplicationContext(),"imageButton被点击",Toast.LENGTH_SHORT).show();
    }
    public void changeImage(View view){
        iv=(ImageView)findViewById(R.id.iv);

        iv.setImageResource(R.drawable.ic_menu_camera);

        Toast.makeText(getApplicationContext(),"设置图片",Toast.LENGTH_SHORT).show();
    }
}
